package org.example.controller;

import org.example.domain.dto.LoginUser;
import org.example.result.VividResult;
import org.example.service.ISysDeptService;
import org.example.service.ISysMenuService;
import org.example.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sys/user")
public class SysLoginController {

    private final ISysUserService sysUserService;
    private final ISysDeptService sysDeptService;
    @Autowired
    private ISysMenuService sysMenuService;

    public SysLoginController(ISysUserService sysUserService, ISysDeptService sysDeptService) {
        this.sysUserService = sysUserService;
        this.sysDeptService = sysDeptService;
    }

    @PostMapping("/login")
    public VividResult login(@RequestBody LoginUser loginUser){
        String token = sysUserService.login(loginUser);
//        System.out.println("部门列表——————————————————"+sysDeptService.selectAllDepts());
//        System.out.println("菜单列表——————————————————"+sysMenuService.getListMenuVos());
        return VividResult.success("登录成功",token);
    }
}
